package com.tte.common.controller;

import com.tte.common.mapstruct.RequestModelMapper;
import com.tte.common.model.tenum.ResultCode;
import com.tte.common.model.vo.RequestModel;
import com.tte.common.model.vo.ResponseModel;
import com.tte.common.model.vo.ResultBean;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用mapstruct转换对象
 * @Author: DongWH
 * @Date: 2023/10/8 15:21
 */
@RestController
@RequestMapping("/mapstruct")
public class MapstructController {

    @PostMapping("/requestToResponse")
    public ResultBean VoConvert(@RequestBody RequestModel requestModel){
        ResponseModel responseModel = RequestModelMapper.INSTANCE.requestToRespsonse(requestModel);

        return new ResultBean(ResultCode.OK,responseModel);
    }

    @PostMapping("/responseToRequest")
    public ResultBean VoConvert(@RequestBody ResponseModel responseModel){
        RequestModel resultModes = RequestModelMapper.INSTANCE.responseToRequest(responseModel);
        return new ResultBean(ResultCode.OK,resultModes);
    }

    @PostMapping("/combinationConver")
    public ResultBean combinationConver(@RequestBody ResponseModel responseModel){
        return RequestModelMapper.INSTANCE.combinationConver(null,null);
    }

}
